﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaskelot.Services.Model;
using Stockholm.SOA.Kaskelot.WCF.Core;

namespace Stockholm.SOA.Kaskelot.WCF.ServiceImplementation.Mapping
{
    public static class AnalysQueryExtensions
    {
        public static DataContracts.Analys.Query ToContract(this AnalysQuery entity)
        {
            DataContracts.Analys.Query q = XmlSerializer<DataContracts.Analys.Query>.DeSerialize(entity.Query);
            q.IsPersonal = !string.IsNullOrEmpty(entity.LoginName);
            q.QueryID = entity.AnalysQueryId;
            return q;
        }

        public static AnalysQuery ToEntity(this DataContracts.Analys.Query q, AnalysQuery entity)
        {
            entity.Namn = q.Name;
            entity.Query = XmlSerializer<DataContracts.Analys.Query>.Serialize(q);

            return entity;
        }
    }
}
